/*
 * @Author: LGX
 * @Date: 2022-03-30 13:32:19
 * @LastEditors: LGX
 * @LastEditTime: 2022-04-11 22:12:50
 * @FilePath: \erp-management-system\src\components\customerseas\ManageBtn.jsx
 * @Description: 公海表格管理按钮,判断权限
 * 
 */
import React, { useState } from 'react'
import { Button, Space, Modal } from 'antd'
import { FormOutlined, DeleteOutlined, PlusSquareOutlined, CheckSquareOutlined, PlusOutlined } from '@ant-design/icons';
import CustomerAdd from '../../views/seas/CustomerAdd'
import DelateCustomer from '../../components/customerseas/Delete'
export default function ManageBtn(props) {
    const [isUpdateModal, setUpdateModal] = useState(false);
    const [isShowDeleta, setisShowDeleta] = useState(false);
    //修改信息modal框
    const handleOkUpdateInfo = () => {
        setUpdateModal(false);
    };  

    const handleUpdateInfo = () => {
        setUpdateModal(false);
    };
    const { permission, userInfo,deleStatus } = props;
    const a = 0
    console.log(permission);
    const cancelDeleta = ()=>{
        setisShowDeleta(false)
    }
    // console.log(props);
    //申请
    const getApply = () => {

    }
    //待审核申请
    const overApply = () => {

    }
    //拒绝申请
    const noApply = () => {

    }
    //通过审核
    const yesApply = () => {

    }
    //修改
    const update = () => {

    }
    //删除
    const del = () => {

    }
    //权限值
    const permissions = (i) => {
        switch (i) {
            case 1:
                return (
                    <>
                        {
                            () => {
                                if (a == 0) {
                                    console.log(11);
                                    return <Button size='small' style={{ backgroundColor: '#3782c3', color: '#fff' }} icon={<FormOutlined />} onClick={yesApply}>审核通过</Button>
                                } else {
                                    return <Button size='small' style={{ backgroundColor: '#ff0000', color: '#fff' }} icon={<DeleteOutlined />} onClick={noApply}>拒绝申请</Button>
                                }
                            }
                        }
                        <Button size='small' style={{ backgroundColor: '#3782c3', color: '#fff' }} icon={<FormOutlined />} onClick={yesApply}>审核通过</Button>
                        <Button size='small' style={{ backgroundColor: '#ff0000', color: '#fff' }} icon={<DeleteOutlined />} onClick={noApply}>拒绝申请</Button>
                        <Button size='small' style={{ backgroundColor: '#3782c3', color: '#fff' }} icon={<FormOutlined />} onClick={() => setUpdateModal(true)}>修改</Button>
                        <Button size='small' style={{ backgroundColor: '#ff0000', color: '#fff' }} icon={<DeleteOutlined />} onClick={()=>setisShowDeleta(true)}>删除</Button>
                    </>

                )
            case 2:
                return <>
                    {
                        () => {
                            if (a == 0) {
                                return <Button size='small' style={{ backgroundColor: '#009966', color: '#fff' }} icon={<PlusSquareOutlined />} onClick={getApply}>申请</Button>
                            } else {
                                return <Button size='small' style={{ backgroundColor: '#ff0000', color: '#fff' }} icon={<DeleteOutlined />} onClick={overApply}>待审核申请</Button>
                            }
                        }
                    }


                </>

        }
    }
    return (
        <>
            <Space size="small">
                {
                    permissions(permission)
                }
            </Space>
            <Modal
                title="修改" visible={isUpdateModal}
                centered
                onOk={handleOkUpdateInfo} onCancel={handleUpdateInfo}
                okText="修改" cancelText='退出'
                bodyStyle={{ height: window.innerHeight * 0.5, overflowY: 'scroll' }}
                width={window.innerWidth * 0.5}>
                <CustomerAdd status={userInfo} />
            </Modal>
            <Modal visible={isShowDeleta} onCancel={cancelDeleta}
                width={500}
                footer={[]}
            >
                <DelateCustomer
                    deleStatus={deleStatus}
                    userInfo={userInfo}
                    setisShowDeleta={setisShowDeleta}
                />
                
            </Modal>
        </>

    )
}
